const AdminBiz = require('../../../../../../comm/biz/admin_biz.js');
const pageHelper = require('../../../../../../helper/page_helper.js');
const projectSetting = require('../../../../public/project_setting.js');
const RequestBiz = require('../../../../../../comm/biz/request_biz.js');

Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		userRegCheck: projectSetting.USER_REG_CHECK,
		searchColumn: 'name',
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: async function (options) {
		if (!AdminBiz.isAdmin(this)) return;
		this.setData({
			isLoad: true
		});
	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function () {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: async function () {},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function () {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function () {
	},

	url: async function (e) {
		pageHelper.url(e, this);
	},


	bindCommListCmpt: function (e) {
		pageHelper.commListListener(this, e);
	},


	bindStatusTap: async function (e) {
		if (!AdminBiz.isAdmin(this)) return;
		let status = pageHelper.dataset(e, 'status');
		let idx = Number(pageHelper.dataset(e, 'idx'));
		let id = Number(pageHelper.dataset(e, 'id'));
		let dataList = this.data.dataList;

		let params = {
			id,
			status,
		}

		let cb = async () => {
			await RequestBiz.request('/api/ysjl/user/status', params).then(res => {
				dataList.list[idx].status = status;
				this.setData({
					dataList: dataList
				});
				pageHelper.showSuccToast('操作成功');
			});
		}

		pageHelper.showConfirm('确认执行此操作?', cb);
	},

})